AZ-204 Quiz

← Back to Topics

Cosmos DB (1 / 62):

You aim to create a Cosmos DB client, a database, and finally a container using the Azure Cosmos DB NoSQL API. Your intention is to utilize this container to manage a collection of IoT device telemetry data. Implementing .NET for this task, you find that after running the following code snippet, errors are encountered and no elements are created as anticipated. Several discrepancies in the code prevent its successful execution. What corrections should you apply to address these issues?

using Azure.CosmosDb;

CosmosClient cosmosClient = new CosmosClient("https://myCosmosAccount.documents.core.windows.net:443/", configuration["CosmosKey"]);

Database database = await cosmosClient.CreateDatabaseIfNotExistsAsync("db");

Container container = await database.CreateContainerAsync(
    id: "id",
    partitionKeyPath: "pk",
    throughput: 200
);


Exam revision: April 11, 2025